package cl.interpreter.statements;

import cl.interpreter.DuplicateVariableException;
import cl.interpreter.Environment;
import cl.interpreter.IncorrectTypeException;
import cl.interpreter.NonExistantVariableException;
import cl.interpreter.RuntimeStack;
import cl.interpreter.Statement;

public class Assignment implements Statement {
    
    private String name;
    private Object value;
    
    public Assignment(String name, Object value) {
        this.name = name;
        this.value = value;
    }
    @Override
    public void execute(RuntimeStack stack, Environment environment) throws DuplicateVariableException, NonExistantVariableException, IncorrectTypeException {
        // should also set the variable in environment since they share the same pointer
        environment.setVariable(name, value);
    }
}
